var succ_ele = document.querySelector(".success");
var err_ele = document.querySelector(".error");
var ipt_user = document.querySelector("#ipt_user");
var ipt_pass = document.querySelector("#ipt_pass");
document.querySelector("button").onclick = function () {
    var user_value = ipt_user.value;
    var pass_value = ipt_pass.value;
    var url = "http://localhost/360mall/lore/login.php";
    url += "?username=" + user_value + "&password=" + pass_value;

    ajax(url, {
        callback: function (res) {
            res = JSON.parse(res);
            if (res.type === "success") {
                succ_ele.style.display = "block";
                setTimeout(function () {
                    succ_ele.style.display = "none";
                    location.href = "./index.html";
                }, 2000);
                setCookie("username", user_value);
            } else {
                err_ele.style.display = "block";
                setTimeout(function () {
                    err_ele.style.display = "none";
                }, 2000);
            }
        },
    });
};